<!-- include tpl=usercp/head title=在线充值 -->
<script type="text/javascript">
function recharge_payment_submit(obj)
{
	var w = $(obj).find("select[name=wealth]").val();
	if(!w){
		$.dialog.alert(p_lang('请选择充值目标'));
		return false;
	}
	var price = $(obj).find("input[name=price]").val();
	if(!price || price == 'undefined'){
		$.dialog.alert(p_lang('请输入要充值的金额'));
		return false;
	}
	if(parseFloat(price)<0.01){
		$.dialog.alert(p_lang('充值金额不能小于0.01元'));
		return false;
	}
	var p = $(obj).find("input[name=payment]:checked").val();
	if(!p || p == 'undefined'){
		$.dialog.alert(p_lang('请选择充值方式'));
		return false;
	}
	var iframe = $(obj).find("input[name=payment]:checked").attr("data-iframe");
	if(iframe == 1){
		var title = $(obj).find("input[name=payment]:checked").attr("data-title");
		var url = api_url('payment','create','type=recharge');
		url += "&wealth="+w+"&price="+price+"&payment="+p;
		$.phpok.json(url,function(rs){
			if(!rs.status){
				$.dialog.alert(rs.info);
				return false;
			}
			var url = get_url("payment","qrcode","id="+rs.info);
			$.dialog.open(url,{
				'title':title,
				'width':'500px',
				'height':'600px',
				'lock':true
			});
		});
		return false;
	}
	var url = get_url('payment','create','type=recharge');
	url += "&wealth="+w+"&price="+price+"&payment="+p;
	$.phpok.open(url);
	return false;
}
</script>
<form method="post" class="form" target="_blank" action="{url ctrl=payment func=create type=recharge/}" onsubmit="return recharge_payment_submit(this)">
<section class="container">
	<div class="m-4">
		<h3 class="m-4 text-center">在线充值</h3>
		<div class="card">
			<div class="card-header">
				在线充值
			</div>
			<div class="card-body">
				<div class="form-group row">
					<div class="col col-sm-3 text-end">充值目标</div>
					<div class="col col-sm-6">
						<select class="form-select" name="wealth">
							<!-- if $id && $rs -->
							<option value="{$rs.id}">{$rs.title} / 充值比：1元 = {$rs.pay_ratio}{$rs.unit}</option>
							<!-- else -->
							<!-- loop from=$rslist key=$k value=$v id=$tmpid -->
							<option value="{$v.id}">{$v.title} / 充值比：1元 = {$v.pay_ratio}{$v.unit}</option>
							<!-- /loop -->
							<!-- /if -->
						</select>
					</div>
				</div>

				<div class="form-group row">
					<div class="col col-sm-3 text-end">充值金额</div>
					<div class="col col-sm-2">
						<input type="text" name="price" id="price" class="form-control" value="{$price}" onchange="checkmoney()" />
					</div>
					<div class="col col-sm-1">
						元
					</div>
				</div>

				<!-- loop from=$paylist key=$key value=$value id=$tmpid -->
				<div class="form-group row">
					<div class="col col-sm-3 text-end">{$value.title}</div>
					<div class="col col-sm-6">
						
						<div class="d-flex ">
							<!-- loop from=$value.paylist key=$k value=$v id=$idxx -->
							<label class="me-3">
						    	<input type="radio" data-iframe="{$v.iframe}" data-title="{$v.title}" class="form-check-input" name="payment" value="{$v.id}"{if !$tmpid.index && !$idxx.index} checked{/if} />
						    	<!-- if $v.logo1 -->
						    	<img src="{$v.logo1}" style="width:40px;"  />
						    	<!-- /if -->
						    	{$v.title}
							</label>
							<!-- /loop -->
						</div>
						
					</div>
				</div>
				<!-- /loop -->
			</div>
		</div>
	</div>
</section>
<div class="submit-info">
	<div class="text-center m-4">
		<input type="submit" value="{lang提交充值}" class="btn btn-lg btn-primary" id="save_button" />
		<input type="button" value="{lang关闭窗口}" onclick="window.close()" class="btn btn-lg btn-danger" id="save_button" />
	</div>
</div>
</form>

<!-- include tpl=usercp/foot -->